import re

one = "abc123"

re_str = "\d+"

# match  一次 从头找
result = re.match(re_str, one)
print(result)
print('>' * 20)

# search 一次 从任意位置
result = re.search(re_str, one)
print(result)
print('>' * 20)

# split 拆分
two = "hello world hello mldn"
split_str = "\s"

result = re.split(split_str, two)
print(result)
print('>' * 20)

# 替换字符串
thre = "abcat"
sub_str = "a"
result = re.sub(sub_str, "#", thre)
print(result)
print('>' * 20)

four = "hello world,fdssdffds;fsd-=,hello admin"
sub_str2 = "(\w+) (\w+)"
result = re.sub(sub_str2, "#", four)
print(result)
result = re.sub(sub_str2, r"\2 \1", four)
print(result)
print('>' * 20)

hanzi = "replace方法"
hanzi_str = "[\u4e00-\u9fa5]+"
result = re.findall(hanzi_str, hanzi)
print(result)
